package com.lge.test;

import java.util.ArrayList;
import java.util.HashMap;

import com.lge.test.R;
import com.lge.yelp.Yelp;


import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class RestarauntAdapter extends ArrayAdapter<String []> {

	private final MainActivity context;
	private final ArrayList<String []> values;
	
	public RestarauntAdapter (Context context, ArrayList<String []> values) {
		super(context, R.layout.restaurant_row, values);
		this.context = (MainActivity) context;
		this.values = values;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.restaurant_row, parent, false);

		ImageView logo = (ImageView) rowView.findViewById(R.id.res_img);
		ImageView rate = (ImageView) rowView.findViewById(R.id.res_rate);
		TextView title = (TextView) rowView.findViewById(R.id.res_title);
		TextView desc = (TextView) rowView.findViewById(R.id.res_desc);
		
		logo.setImageResource(context.getResources().getIdentifier(values.get(position)[0], "drawable", "com.lge.test"));
		title.setText(values.get(position)[2]);
		desc.setText(values.get(position)[3]);
		
		new YelpTask(context, rate).execute(values.get(position)[2]);
		
		return rowView;
	}
	
}
